﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JTicket.UI
{
    public partial class S_OperSaleReport : System.Web.UI.Page
    {
        private readonly BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                Bind();
        }
        void Bind()
        {
            string thcode = bllOper.Oper().ThCode;
            List<Model.C_CodeNote> codenote = DAL.C_CodeNote.GetListAllByGroupCod("TitleSort");
            DropDownList1.DataSource = codenote;
            DropDownList1.DataTextField = "CodeNote";
            DropDownList1.DataTextField = "CodeNote";
            DropDownList1.DataBind();
            DropDownList1.Items.Insert(0, new ListItem("所有","0"));
            this.TextBox1.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.TextBox2.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.TextBox3.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.TextBox4.Text = DateTime.Now.ToString("yyyy-MM-dd");
            DateTime bdate = Convert.ToDateTime(this.TextBox1.Text + " 00:00:00");
            DateTime edate = Convert.ToDateTime(this.TextBox2.Text + " 23:59:59");
            dg1.DataSource = DAL.D_TitleInfo.GestListAll(thcode, bdate, edate);
            dg1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string thcode = bllOper.Oper().ThCode;
            DateTime bdate = Convert.ToDateTime(this.TextBox1.Text + " 00:00:00");
            DateTime edate = Convert.ToDateTime(this.TextBox2.Text + " 23:59:59");
            if (DropDownList1.SelectedItem.Value == "0")
            {
                dg1.DataSource = DAL.D_TitleInfo.GestListAll(thcode, bdate, edate);
                dg1.DataBind();
            }
            else
            {
                dg1.DataSource = DAL.D_TitleInfo.GestListAll(thcode, bdate, edate, DropDownList1.SelectedItem.Value);
                dg1.DataBind();
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            string YX_CH = Request.Form["YX_CH"]; 
            Response.Redirect("S_SaleReport.aspx?Bdate="+this.TextBox3.Text
                + "&Edate=" + this.TextBox4.Text + "&StitleCode=" + YX_CH + "");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }
        protected void dg1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemIndex == -1) return;
            e.Item.Attributes.Add("bgcolor", "#EFFFDA");
            e.Item.Attributes.Add("style", "cursor:hand");
            e.Item.Attributes.Add("onMouseOver=this.style.backgroundColor", "#DBE3FA");
            e.Item.Attributes.Add("onMouseOut=this.style.backgroundColor", "#F6F6F6");

        }
    }
}